<?php

namespace App\Http\Controllers\Home;

use App\Http\Model\Article;
use App\Http\Model\Nav;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Http\Model\Link;
class CommonController extends Controller
{
    public function __construct()
    {
        //        1 导航栏数据      $nav
        $nav = Nav::orderBy('nav_order','asc')->take(7)->get();
        //        2 最新文章   8篇  $news
        $news = Article::orderBy('art_time','desc')->take(8)->get();
        //        3 点击排行榜文章 5篇  $hot
        $hot = Article::orderBy('art_view','asc')->take(5)->get();
        //        4 友情链接
        $link = Link::orderBy('link_name','asc')->take(3)->get();
        view()->share('nav', $nav);
        view()->share('news', $news);
        view()->share('hot', $hot);
        view()->share('link',$link);
    }
}
